package cn.new18.testactivitytask.aFragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.lzy.okgo.OkGo;

import cn.new18.testactivitytask.Constants.Url;
import cn.new18.testactivitytask.R;
import cn.new18.testactivitytask.base.LazyFragment;
import cn.new18.testactivitytask.bean.TopBean;
import cn.new18.testactivitytask.bean.VideoBean;

/**
 * Created by RaoWei on 2016/11/22 13:23.
 */

public class FragC extends LazyFragment {

    private String Tag = this.getClass().getSimpleName();
    private static FragC mFragC;
    private TextView mText;

    @Override
    protected View setContainerView() {
        View inflate = View.inflate(getContext(), R.layout.fragc, null);
        mText = (TextView) inflate.findViewById(R.id.fragc);
        return inflate;
    }

    public static Fragment newInstance() {
        if (mFragC == null) {
            mFragC = new FragC();
        }
        return mFragC;
    }

    @Override
    protected void OnErrorImgClick() {
        okGoRequest();

    }

    @Override
    protected void onFirstUserVisible() {
        Log.e(Tag, "first_show");
        okGoRequest();
    }

    private void okGoRequest() {
        OkGo.get(Url.TOP).execute(new LoadingViewCallBack<TopBean.DataBean>(TopBean.DataBean.class) {
            @Override
            protected void onLoadSuccess(TopBean.DataBean dataBean) {
                mText.setText(dataBean.getProducts().get(0).getGroupName());
            }
        });
    }

    @Override
    protected void onUserInvisible() {
        Log.e(Tag, "hide");
    }

    @Override
    protected void onUserVisible() {
        Log.e(Tag, "show");
    }


   /* @Override
    public void onResume() {
        super.onResume();
        Log.e(Tag, "onResume");
    }

    @Override
    public void onPause() {
        super.onPause();
        Log.e(Tag, "onPause");
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        Log.e(Tag, "onDestroyView");
    }

    @Override
    public void setUserVisibleHint(boolean isVisibleToUser) {
        super.setUserVisibleHint(isVisibleToUser);
        Log.e(Tag, "setUserVisibleHint, getUserVisibleHint = " + getUserVisibleHint());
    }*/
}
